﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.SceneManagement;

public class GameResult : MonoBehaviour {

	public Image num1;
	public Image num2;
	public Image num3;
	public Image num4;
	void Start () {
		
	}
	
	void Update () {
		
	}

	public void GameOver(){
		//Time.timeScale = 0f;
		int score = GetComponent<ScoreCounter> ().currentScore;
		var imageList = GetComponent<ScoreCounter> ().imageList;
		int one = score % 10;
		int two = score % 100 / 10;
		int three = score % 1000 / 100;
		int four = score % 10000 / 1000;
		num1.sprite = imageList [one];
		num2.sprite = imageList [two];
		num3.sprite = imageList [three];
		num4.sprite = imageList [four];
	}

	public void ReTry(){
		//Time.timeScale = 1;
		AudioManager.instance.StopAllAudio ();
		Scene scene = SceneManager.GetActiveScene(); 
		SceneManager.LoadScene(scene.name);
	}

	public void Index(){
		//Time.timeScale = 1;
		AudioManager.instance.StopAllAudio ();
		SceneManager.LoadScene ("Index");
	}

	public void pause(){
		if (Time.timeScale == 1) {
			Time.timeScale = 0f;
		} else {
			Time.timeScale = 1;
		}
	}
}
